package com.example.demo.util;

import java.math.BigInteger;

/**
 * @Classname AutoAddOne
 * @Description java实现6位的16进制递增
 * @Date 2019/8/22 9:22
 * @Created by yby
 */
public class AutoAddOne {

    public static char[] hexs = "0123456789ABCDEF".toCharArray();


    //將10進制轉換為16進制
    public static String encodeHEX(Integer numb) {

        String hex = Integer.toHexString(numb);
        return hex;

    }


    //將16進制字符串轉換為10進制數字
    public static int decodeHEX(String hexs) {
        BigInteger bigint = new BigInteger(hexs, 16);
        int numb = bigint.intValue();
        return numb;
    }


    public static void main(String[] args) {
        //16进制6位  共 一千五百万
        //int numb=16*16*16*16*16; //15000000
        /*int numb=2147483647; //15000000
        String hex=	encodeHEX(numb).toUpperCase();
        System.out.println("  9999  的16进制为"+hex);
        System.out.println("    16進制字符 "+hex+" 的10進制數字為   "+decodeHEX("100027"));

        if(Long.parseLong("100027",16)<Long.parseLong("10002c",16)){
            System.out.println(Long.parseLong("100027", 16));
            System.out.println("100027大");
        }

        int i = decodeHEX("2147483647");//从该位开始递增
        System.out.println("i="+i);*/

        int start = 16 * 16 * 16 * 16 * 16;//从该位开始递增
        String hex = "";
        for (int i = 0; i < 10; i++) {
            start++;
            hex = encodeHEX(start).toUpperCase();
            System.out.println("hex=" + hex);
        }
    }
}
